#ifdef __cplusplus
extern "C"{
#endif
#ifndef __XS_EPOLL_H__
#define __XS_EPOLL_H__

#ifdef WIN32

#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>

typedef SOCKET XSOCKET;
#define EINPROGRESS WSAEWOULDBLOCK

#define EPOLLIN 1
#define EPOLLOUT 2
#define EPOLL_CTL_DEL 0
#define EPOLL_CTL_MOD 1
#define EPOLL_CTL_ADD 2

struct epoll_event
{
    union
    {
        void* ptr;
    } data;
    int events;
};

#define xs_close_socket closesocket

#else
#include <sys/epoll.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <netdb.h>
#endif

typedef int XSOCKET;
typedef struct epoll_event 		xs_epoll_event;

#define MAX_EPOLL_SIZE 0x40  
#define THREADS_COUNT 0x04


#define EPOLL_DEFAULT_SIZE		MAX_EPOLL_SIZE
#define xs_default_listen_size		MAX_EPOLL_SIZE
#define xs_defult_thread_size		THREADS_COUNT
//int xs_inet_pton(int , const char *, void *);
int xs_socketpair(int , int , int , XSOCKET socks[2]);

int xs_epoll_ctl(int , int , XSOCKET , struct epoll_event* );
int xs_epoll_create(int);
int xs_epoll_wait(int , struct epoll_event* , int , int );
int xs_epoll_close(int );

#define epoll_wait_indefinite			(-1)
#define epoll_return_immediate		(0)

int xs_epoll_entry();
#endif

#ifdef __cplusplus
}
#endif
